// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-6-30

#ifndef __LOBBYINDEX_H_CLIENT_MAIN__
#define __LOBBYINDEX_H_CLIENT_MAIN__


#pragma once

#include <common\ui\wnd.h>
#include <common\ui\checkbox.h>
#include <common\ui\listview.h>
#include <common\ui\wndcontainer.h>
#include "JoyLobbyBox.h"

class CJoyLobbyIndex;
class CJoyLobbyGroup;
class CJoyLobbyListView;
class CJoyLobbyBox;

//##ModelId=44C4B5E20261
class CJoyLobbyItem : public CJoyListViewItem
{
public:
    friend class CJoyLobbyIndex;

	//##ModelId=44C4B5E20264
    CStringW        m_title;
	//##ModelId=44C4B5E20272
    CJoyImagePtr    m_icon;
	//##ModelId=44C4B5E20276
    int             m_gameId;
	//##ModelId=44C4B5E20277
    UINT            m_lobbyId;
	//##ModelId=44C4B5E20280
    int             m_titleStart;
	//##ModelId=44C4B5E20281
    int             m_imageStart;
	//##ModelId=44C4B5E20283
    Color           m_selTextColor;
	//##ModelId=44C4B5E20290
    CString         m_helpNote;

	//##ModelId=44C4B5E20291
    void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44C4B5E2029F
    virtual void CM_Draw(Graphics& graph);
public:
	//##ModelId=44C4B5E202A2
    CJoyLobbyItem(void);
	//##ModelId=44C4B5E202B0
    virtual ~CJoyLobbyItem(void);

	//##ModelId=44C4B5E202BF
    CJoyLobbyListView* GetListView() const
    {
        return (CJoyLobbyListView*)m_listView;
    }
	//##ModelId=44C4B5E202C1
    CJoyLobbyGroup* GetLobbyGroup() const;
};

//##ModelId=44C4B5E202CE
class CJoyLobbyListView : public CJoyListView
{
	DECLARE_DYNAMIC(CJoyLobbyListView)
public:
    friend class CJoyLobbyIndex;

	//##ModelId=44C4B5E202D1
    CJoyLobbyGroup* m_lobbyGroup;
	//##ModelId=44C4B5E202DF
    CJoyLobbyIndex* m_lobbyIndex;
public:
	//##ModelId=44C4B5E202E3
    CJoyLobbyListView(void);
	//##ModelId=44C4B5E202E5
    virtual ~CJoyLobbyListView(void);

	//##ModelId=44C4B5E202EF
    CJoyLobbyItem* FindItem(UINT lobbyId);

public:
    DECLARE_MESSAGE_MAP()
};

//##ModelId=44C4B5E2030D
class CJoyLobbyGroup : public CJoyWnd
{
	DECLARE_DYNAMIC(CJoyLobbyGroup)
public:
    friend class CJoyLobbyIndex;

	//##ModelId=44C4B5E20310
    CJoyCheckBox*   m_titleCheck;
	//CJoyLobbyBox *    m_titleCheck;
	//##ModelId=44C4B5E20315
    CJoyLobbyListView*  m_lobbyView;
	//##ModelId=44C4B5E2031F
    CJoyLobbyIndex* m_lobbyIndex;

	//##ModelId=44C4B5E20323
    void CM_TitleCheck(CJoyCheckBox*, bool& checked);
public:
	//##ModelId=44C4B5E2032C
    CString m_title;
public:
	//##ModelId=44C4B5E2032D
    CJoyLobbyGroup(void);
	//##ModelId=44C4B5E2032F
    virtual ~CJoyLobbyGroup(void);

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5E2033E
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

//##ModelId=44C4B5E2034B
class CJoyGroupContainer : public CJoyWndContainer
{
	DECLARE_DYNAMIC(CJoyGroupContainer)
protected:
	//##ModelId=44C4B5E2034D
    virtual void CM_Draw(Graphics& graph);
public:
	//##ModelId=44C4B5E2035C
    CJoyGroupContainer(void);
	//##ModelId=44C4B5E2035E
    virtual ~CJoyGroupContainer(void);

public:
    DECLARE_MESSAGE_MAP()
};

//##ModelId=44C4B5E2037A
class CJoyLobbyIndex :
    public CJoyWnd
{
	/*Adds the ability to access run-time information about
	an object's class when deriving a class from CObject.
	*/
	DECLARE_DYNAMIC(CJoyLobbyIndex)
public:
	//##ModelId=44C4B5E30022
    typedef void (CJoyWnd::*PSelItem)(CJoyLobbyItem* item);
	//##ModelId=44C4B5E3002E
    typedef void (CJoyWnd::*PUnCheckAllGroup)();
protected:
    friend class CJoyLobbyGroup;


	//##ModelId=44C4B5E2038C
    CJoyLobbyGroup* m_currentGroup;
	//##ModelId=44C4B5E20391
    CJoyCheckGroup  m_checkGroup;

	//##ModelId=44C4B5E2039A
    CJoyButton* m_btnUp;
	//##ModelId=44C4B5E2039F
    CJoyButton* m_btnDown;

	//##ModelId=44C4B5E203AA
    CJoyWnd*    m_uncheckCtrl;
	//##ModelId=44C4B5E203AF
    PUnCheckAllGroup    m_uncheckEvent;

	//##ModelId=44C4B5E203B3
    virtual void CM_UpDownClick(CJoyButton* btn);
	//##ModelId=44C4B5E203BB
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
public:
	//##ModelId=44C4B5E203C9
    CList<CJoyLobbyGroup*>  m_groups;
	//##ModelId=44C4B5E203CE
    CList<CJoyLobbyItem*>   m_lobbyItems;
	//##ModelId=44C4B5E203D8
    bool    m_isInLobbyPage;
public:
	//##ModelId=44C4B5E203D9
    CJoyLobbyIndex(void);
	//##ModelId=44C4B5E203DB
    virtual ~CJoyLobbyIndex(void);

	//##ModelId=44C4B5E30000
    void SetSelItemEvent(CJoyWnd* pWnd, PSelItem pOnSel);
	//##ModelId=44C4B5E30003
    void SetUncheckAllEvent(CJoyWnd* pWnd, PUnCheckAllGroup pOnUncheck);
	//##ModelId=44C4B5E30011
    void SelectLobby(UINT lobbyId);

public:
	/* Declares that the class defines a message map. 
	Each CCmdTarget-derived class in your program must 
	provide a message map to handle messages.
    */

    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5E3001F
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

//##ModelId=44C4B5E202C1
inline CJoyLobbyGroup* CJoyLobbyItem::GetLobbyGroup() const
{
    return GetListView()->m_lobbyGroup;
}

#endif  // __LOBBYINDEX_H_CLIENT_MAIN__
